package com.ids.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import com.ids.util.DbManager;
import com.ids.util.Utlity;

public class AdminChangeEmployeePasswordDao {
	private AdminChangeEmployeePasswordDao instance = new AdminChangeEmployeePasswordDao();

	public AdminChangeEmployeePasswordDao getInstance() {
		return instance;
	}

	public static String insertChangedPassword(String empCode,
		String newPassword, String confirmPassword) {
		String result = "";
		DbManager dbManager = new DbManager();  
		Connection conn = dbManager.getConnection();
		if (newPassword.equals(confirmPassword)) {
			String updatePassword = "update logininfo set password =? where empCode=?";
			try {
				PreparedStatement prepStmt = conn
						.prepareStatement(updatePassword);
				prepStmt.setString(1, Utlity.MD5(newPassword));
				prepStmt.setString(2, empCode);
				prepStmt.execute();
				System.out.println("ww");
				result = "success";
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return result;
	}

}
